Component({
    properties: {
        actions: {
            type: Array,
            value: () => {
                return []
            }
        },
        data: {
            type: String/Number,
            value: ''
        },
        bottom: {
            type: Number,
            value: 110
        }
    },
    data: {
        isOpen: false,
        maskShow: false,
        listShow: false,
        safeAreaHeight: 0
    },
    lifetimes: {
        attached() {
            const app = getApp();
            this.setData({
                safeAreaHeight: app.globalData.safeAreaHeight
            })
        }
    },
    methods: {
        open() {
            this.setData({
                isOpen: true
            })
            setTimeout(() => {
                this.setData({
                    maskShow: true,
                    listShow: true
                })
            }, 10)
        },
        close() {
            this.setData({
                maskShow: false,
                listShow: false
            })
            setTimeout(() => {
                this.setData({
                    isOpen: false
                })
            }, 200)
        },
        onSelect(e) {
            let action = e.currentTarget.dataset.action
            let index = e.currentTarget.dataset.index
            let data = this.data.data
            this.triggerEvent('select', {
                action: action,
                index: index,
                data: data
            })
            this.close();
        }
    }
})